
//
//  JShopCarHeaderView.m
//  HeadIndustry
//
//  Created by jun on 2017/9/4.
//  Copyright © 2017年 jun. All rights reserved.
//

#import "JShopCarHeaderView.h"

@interface JShopCarHeaderView()

@property (nonatomic , strong) YYLabel *VendorName; // 店铺名字
@property (nonatomic , strong) UIButton *selBtn;
@property (nonatomic , strong) UIButton *editingBtn;

@end

@implementation JShopCarHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        self.opaque = NO;
        self.backgroundColor = [UIColor whiteColor];
        
        [self setUpHeaderView];
    }
    return self;
}

- (void)setUpHeaderView {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(5, 15, 50, 30);
    
    [button setImage:[UIImage imageNamed:@"yuank"] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:@"yesred"] forState:UIControlStateSelected];
    [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:button];
    self.selBtn = button;
    
    YYLabel *label = [[YYLabel alloc]init];
    label.frame = CGRectMake(70, 15, kWindowW - 100, 30);
    label.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:label];
    self.VendorName = label;
    
    
    UIButton *editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    editBtn.frame = CGRectMake(kWindowW - 10 - 50, 15, 50, 30);
    [editBtn setTitle:@"编辑" forState:UIControlStateNormal];
    [editBtn setTitle:@"完成" forState:UIControlStateSelected];
    editBtn.titleLabel.font = kFONT_TITLE(16);
    [editBtn setTitleColor:kRGBColor(139, 139, 139) forState:UIControlStateNormal];
    editBtn.selected = NO;
    [editBtn addTarget:self action:@selector(beditingBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:editBtn];
    self.editingBtn = editBtn;
}

- (void)buttonClick:(UIButton*)button {
    button.selected = !button.selected;
    
    if (self.JSelectBlock) {
        self.JSelectBlock(button.selected);
    }
}

- (void)beditingBtnClick:(UIButton*)button {
    button.selected = !button.selected;
    
    if (self.JEditBlock) {
        self.JEditBlock(button.selected);
    }
}

- (void)setEditing:(BOOL)editing
{
    _editing = editing;
    self.editingBtn.selected = editing;
}

- (void)setSelect:(BOOL)select {
    
    self.selBtn.selected = select;
    _select = select;
}

- (void)setTitle:(NSString *)title {
    self.VendorName.text = title;
    _title = title;
}


@end
